<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />

</head>
<style>
    ::-webkit-scrollbar {display:none}/*隐藏横向滚动条但可以滚动*/
</style>
<body>
<form class="layui-form">
    <input name="hourid" type="hidden" th:value="${studenthuor.hourid}"/>
    <input name="floorid" type="hidden" th:value="${studenthuor.floorid}"/>
    <input name="count" type="hidden" th:value="${studenthuor.count}"/>
    <div class="layui-form-item">
        <label class="layui-form-label">宿舍房号</label>
        <div class="layui-input-inline">
            <input  name="huorname" autocomplete="off"  placeholder="请输入宿舍房号"  th:value="${studenthuor.huorname}"class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">所在楼栋</label>
        <div class="layui-input-inline">
            <select   name="floorid" id="floorid"  >
                <option th:each="class:${studentFloorList}" th:value="${class.floorid}" th:text="${class.floorname}" th:selected="${class.floorid==studenthuor.floorid}"></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">总床位数</label>
        <div class="layui-input-inline">
            <input  name="numberbeds" autocomplete="off"  placeholder="请输入床位数" th:value="${studenthuor.numberbeds}"class="layui-input"/>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">宿舍地址</label>
        <div class="layui-input-inline" >
            <input  name="addr" id="addr" autocomplete="off"  placeholder="请输入宿舍地址"  th:value="${studenthuor.addr}"class="layui-input"/>
        </div>
    </div>





    <div class="layui-form-item" style="margin-left: 130px">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-radius layui-btn-normal" lay-submit lay-filter="formDemo">立即提交</button><!--测试提交值的时候把 lay-filter="formDemo"注释掉可直接提交-->
            <button type="reset" class="layui-btn layui-btn-radius layui-btn-warm">重新填写</button>
        </div>
    </div>
</form>
</body>
<script th:src="@{/js/register/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>

<script type="text/javascript" th:inline="none">




    layui.use('form', function(){
        var form = layui.form;
        //监听提交
        //你可以在这里做操作  也可以不使用这个方法
        form.on('submit(formDemo)', function(data){
            $.ajax({
                url: '/studentHuor/update',
                type: 'post',
                data:data.field,
                dataType: 'json',
                success:function(data){
                    if(data != 0){
                        //先得到当前iframe层的索引
                        var index = parent.layer.getFrameIndex(window.name);
                        //再执行关闭
                        parent.layer.close(index);
                        layer.msg(JSON.stringify("修改成功"));
                        window.parent.location.reload();
                    }else {
                        layer.msg('数据错误，修改失败！', { icon: 5, time: 2000 });
                    }
                },
            })
            return false;
        });

    });


</script>
</html>